package main.java;

import java.util.Vector;

public class Test {
    public static void main(String[] args) {
        while (true) {
            try {
                Vector<Integer> vector = new Vector<>();
                for (int i = 0; i < 10; i++) {
                    vector.add(i);
                }
                Thread t1 = new Thread(() -> {
                    try {
                        for (int i = 0; i < vector.size(); i++) {
                            Integer getI = vector.get(i);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                });
                Thread t2 = new Thread(() -> {
                    for (int i = 0; i < vector.size(); i++) {
                        vector.remove(i);
                    }
                });
                t1.start();
                t2.start();
                while (Thread.activeCount() > 20);
            } catch (Exception e) {
                e.printStackTrace();
                break;
            }
        }
    }
}
